<template>
  <div class="control">
    <div v-for="(item,index) in titles" :key="index" :class="{active : index=== a1}" @click="f1(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  data(){
    return{
      a1 : 0
    }
  },
  props:{
    titles:{
      type:Array,
      default(){
        return[]
      }
    }
  },
  methods:{
    f1(index){
      this.a1=index
      this.$emit('tabcontrol',index)
    }
  }
}
</script>

<style>
.control{
  display: flex;
  height:40px;
  line-height: 40px;
  text-align: center;
  position: sticky;
  top: 43px;
  z-index: 3;
  background-color: blanchedalmond;

}
.control div{
  flex:1;
}
span{
  padding: 5px;
}
.active{
  color: pink;
}
.active span{
  border-bottom: pink 3px solid;
}

</style>